package protocol;

import com.netease.task.TransTypeCode;


public class XoneServiceCode implements TransTypeCode{
	/**
	 *	公共消息段定义
	 * 
	 */
	public static final int SERVICE_MSG_CODE = 0x1000;//客户端本地生成的code
	public static final int SERVICE_HTTP_CODE = 0x2000;//http协议本身返回code
	public static final int SERVICE_PROTOCOL_CODE_COMMON = 0x3000; //协议返回的全局code
	public static final int SERVICE_PROTOCOL_CODE_API = 0x6000; //具体api返回的code
	
	/**
	 *	transaction公共code
	 *  
	 */
	public static final int TRANSACTION_SUCCESS = SERVICE_MSG_CODE + 0x001;
	// 事件执行失败
	public static final int TRANSACTION_FAIL 	= SERVICE_MSG_CODE + 0x002;
	
	/**
	 * Net 网络错误值.
	 */
	 public static final int NETWORK_ERR = SERVICE_HTTP_CODE;
	 public static final int NETWORK_ERR_COMMON = SERVICE_HTTP_CODE + 1 ;
	 
//	// 网络安全异常错误
//	public static final int ERR_NETWORK_SECURITY = SERVICE_HTTP_CODE + 1;
//	// 网络无法链接
//	public static final int ERR_NETWORK_DONT_CONNECT = SERVICE_HTTP_CODE + 2;
//	// 其它网络错误
//	public static final int ERR_NETWORK_OTHER = SERVICE_HTTP_CODE + 3;
//	// 网络请求取消
//	public static final int ERR_NETWORK_CANCEL = SERVICE_HTTP_CODE + 4;
	
	/**
	 *	protocol全局code
	 *  
	 */
	 public static final int PROTOCOL_CODE_SUCCESS = SERVICE_PROTOCOL_CODE_COMMON;
	 public static final int PROTOCOL_COOKIE_INVALID = SERVICE_PROTOCOL_CODE_COMMON + 1;
	 public static final int PROTOCOL_CODE_NOT_AUTHORITY = SERVICE_PROTOCOL_CODE_COMMON + 2;
	 public static final int PROTOCOL_CODE_SEVER_ERROR = SERVICE_PROTOCOL_CODE_COMMON + 3;
	 public static final int PROTOCOL_CODE_VERSION_UNSUPPORTS = SERVICE_PROTOCOL_CODE_COMMON + 4; // 客户端版本过低
	 public static final int PROTOCOL_CODE_UNKNOW_ERROR = SERVICE_PROTOCOL_CODE_COMMON + 5;
	 public static final int PROTOCOL_CODE_ARGUMENTS_INVALID  = SERVICE_PROTOCOL_CODE_COMMON + 6;
	 public static final int PROTOCOL_CODE_ENCRYPT_ERROR = SERVICE_PROTOCOL_CODE_COMMON + 7;
	
	 /**
	  *	protocol具体api返回code
	  *  
	 */
	 /**
	 * 登录注册
	 */
		public static final int LOGINREG_ERROR = SERVICE_PROTOCOL_CODE_API + 0x100;
	    public static final int LOGINREG_ERR_XONE_USERNONE = LOGINREG_ERROR + 1;// 用户未注册
	    public static final int LOGINREG_ERR_NICKNAME_EXIST = LOGINREG_ERROR + 2;// 用户昵称已经存在
	    public static final int LOGINREG_ERR_USER_EXIST = LOGINREG_ERROR + 3;// 用户已注册
	    public static final int LOGINREG_ERR_ACC_PW_ERROR = LOGINREG_ERROR + 4;// 用户名密码错误
	    public static final int LOGINREG_ERR_USER_LOCKED = LOGINREG_ERROR + 5;// 账号被锁定
	    public static final int LOGINREG_ERR_CAPTCHA_INVALID = LOGINREG_ERROR + 6;// 验证码失效
	    public static final int LOGINREG_ERR_CAPTCHA_ERROR = LOGINREG_ERROR + 7;// 验证码错误
	    public static final int LOGINREG_ERR_EXTERNAL_VERIFY_ERROR = LOGINREG_ERROR + 8;// 第三方验证失败
	    public static final int LOGINREG_ERR_MOBILE_MESSAGE_COUNT_EXCEED = LOGINREG_ERROR + 9;// 短信请求次数超过系统限制
	    public static final int LOGINREG_ERR_NICKNAME_LENGTH_EXCEED = LOGINREG_ERROR + 10;//昵称太长
	    public static final int LOGINREG_ERR_NICKNAME_INVAILD = LOGINREG_ERROR + 11;//昵称出现非法字符
	    public static final int LOGINREG_ERR_SIGNATURE_LENGTH_ERROR = LOGINREG_ERROR + 12;//签名长度不正确
	    
	    /**
	     * 其它，根据具体协议处理
	     */
	        public static final int PROTOCOL_GENERAL_ERROR = SERVICE_PROTOCOL_CODE_API + 0x200;
	        public static final int ERROR_CONTENT_NOTEXIST  = PROTOCOL_GENERAL_ERROR + 1;// 请求资源不存在：如根据不存在的昵称获取用户信息
	        public static final int ERROR_ILLEGAL_CONTENT = PROTOCOL_GENERAL_ERROR + 2;// 非法内容，内容不够河蟹
	       
	        public static final int ERROR_FOLLOWCOUNT_EXCEEDED = PROTOCOL_GENERAL_ERROR + 3;// 关注数量达到上限
	        public static final int ERROR_SENDLETTER_REJECTED = PROTOCOL_GENERAL_ERROR + 4;//对方拒绝接收

	
	public static int protocolCodeToClientCode(int code) {
        int result = code;
		switch (code) {	
			case 0:
				result = PROTOCOL_CODE_SUCCESS;
			break;
			case 11://用户未登录
                result = PROTOCOL_COOKIE_INVALID;
            break;
			case 12:// 用户访问资源受限
                result = PROTOCOL_CODE_NOT_AUTHORITY;
            break;
			case 13:// 服务器异常
                result = PROTOCOL_CODE_SEVER_ERROR;
            break;
			case 14://加密ID或密钥失效 
			    result = PROTOCOL_CODE_ENCRYPT_ERROR;
			break;
			case 15:// 客户端版本过低
                result = PROTOCOL_CODE_VERSION_UNSUPPORTS;
            break;
			case 16://请求参数错误或参数缺失
                result = PROTOCOL_CODE_ARGUMENTS_INVALID;
            break;
			case 101:// 用户未注册
			    result = LOGINREG_ERR_XONE_USERNONE;
			break;
			case 102://用户昵称已经存在
                result = LOGINREG_ERR_NICKNAME_EXIST;
            break;
			case 103://用户已注册
                result = LOGINREG_ERR_USER_EXIST;
            break;
			case 104://用户名密码错误
                result = LOGINREG_ERR_ACC_PW_ERROR;
            break;
			case 105://账号被锁定
                result = LOGINREG_ERR_USER_LOCKED;
            break;
			case 106://验证码失效
                result = LOGINREG_ERR_CAPTCHA_INVALID;
            break;
			case 107://验证码错误
                result = LOGINREG_ERR_CAPTCHA_ERROR;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            break;
			case 108://第三方验证失败
                result = LOGINREG_ERR_EXTERNAL_VERIFY_ERROR;
            break;
			case 109://短信请求次数超过系统限制
                result = LOGINREG_ERR_MOBILE_MESSAGE_COUNT_EXCEED;
            break;
			case 110://昵称太长
                result = LOGINREG_ERR_NICKNAME_LENGTH_EXCEED;
            break;
			case 111://昵称出现非法字符
                result = LOGINREG_ERR_NICKNAME_INVAILD;
            break;
			case 112://签名长度不正确
                result = LOGINREG_ERR_SIGNATURE_LENGTH_ERROR;
            break;
			case 1001://请求资源不存在：如根据不存在的昵称获取用户信息
                result = ERROR_CONTENT_NOTEXIST;
            break;
            case 1002://非法内容，内容不够河蟹
                result = ERROR_ILLEGAL_CONTENT;
            break;
            case 3001://关注数量达到上限
                result = ERROR_FOLLOWCOUNT_EXCEEDED;
            break;
            case 201://对方拒绝接收
                result = ERROR_SENDLETTER_REJECTED;
            break;
			default:
				break;
		}
		return result;
	}
	
}
